
digits = "23"
var letterCombinations = function(digits) {
       if (digits.length === 0) return [];
    
    const digitToLetters = {
        '2': 'abc',
        '3': 'def',
        '4': 'ghi',
        '5': 'jkl',
        '6': 'mno',
        '7': 'pqrs',
        '8': 'tuv',
        '9': 'wxyz'
    };
      const result=[]
      const backtrack=(index,currentCombination)=>{
               if(index===digits.length){
            result.push(currentCombination)
            return
      }
         const current=digitToLetters[digits[index]]
         for(let i=0;i<current.length;i++)
         {
            backtrack(index+1,currentCombination+current[i])
         }
      }
      
     
         backtrack(0,"")
         return result




};
console.log(letterCombinations(digits));
